#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T=int>
inline T read() {
    T x;
    cin >> x;
    return x;
}
const int maxn = 2e5 + 500;
int book[maxn], n;
vector<int> a, b;
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t = read();
        book[t] = 1;
    }
    for (int i = 1; i <= 2 * n; i++) {
        if (book[i]==1)
            b.push_back(i);
        else
            a.push_back(i);
    }
    int p = 0, win = 0;
    for (int e: a) {
        
        int q=upper_bound(b.begin(),b.end(),e)-b.begin();
        if (q > p) {
            ++win;
            p++;
        }
    }
    cout << win << endl;
    return 0;
}